<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class logfile_model extends CI_Model {

	public function get_logfile($log_status ,$per_page ,$uri)
	{
		if($log_status != 'all')
		{
			$this->db->where('log_status',$log_status);
		}

		$this->db->limit($per_page ,$uri);
		$this->db->order_by('log_date' ,'desc');
		$this->db->join('member','member.mem_id = log_file.mem_id','left');
		$query = $this->db->get('log_file');
		return $query->result_array();
	}

	public function count_logfile($log_status)
	{
		if($log_status != 'all')
		{
			$this->db->where('log_status',$log_status);
		}

		$this->db->order_by('log_date' ,'desc');
		$this->db->join('member','member.mem_id = log_file.mem_id','left');
		$query = $this->db->get('log_file');
		return $query->result_array();
	}

	public function add_logfile($log_file)
	{
		$this->db->insert('log_file' ,$log_file);
	}

	// public function count_search()
	// {
	// 	$this->db->join('member','member.mem_id = log_file.mem_id','left');
	// 	$query = $this->db->get('log_file');
	// 	return count($query->result_array());
	// }



	public function get_vdo($per_page ,$uri ,$result_by ,$category_by)
	{
		if($this->uri->segment(1) == 'pvdo' || $this->uri->segment(1) == 'pslide')
		{
			$this->db->limit($per_page ,$uri);
			$this->db->order_by($result_by ,'desc');
			if($category_by != 'all')
			{
				$this->db->where('category.category_id',$category_by);
				$this->db->join('category','category.category_id = vdo.category_id','left');
			}
		}		
		$this->db->where('thumb_choose',1);
		$this->db->join('vdo_thumb','vdo_thumb.vdo_id = vdo.vdo_id','left');
		$query = $this->db->get('vdo');
		return $query->result_array();
	}
}